﻿/**
创建：卢龙
时间：2018年2月8日
说明：基于layui的弹出框
引用此文件须先引用layui.js
*/

var dialog = {};

layui.use('layer', function () {
    var layer = layui.layer;
    //信息弹框
    dialog.info = function (msg) {
        layer.msg(msg);
    };
    //系统提示弹框
    dialog.prompt = function (msg) {
        layer.open({
            title: "系统提示",
            content: msg
        });
    };
    //确认提示弹框
    dialog.confirm = function (title, msg) {
        layer.open({
            title: title,
            content: msg
        });
    };
    //确认取消系统提示框
    dialog.dialog = function (msg, callback) {
        layer.open({
            title: "系统提示",
            content: msg,
            btn: ['确认', '取消'],
            yes: function (index, layero) {
                callback();
                layer.close(index)
            }
        });
    };
    //加载提示框
    dialog.loading = function () {       
        layer.open({
            type: 1
            , title: false 
            , closeBtn: false
            , area: '200'
            , shade: 0.8
            , id: "1" //设定一个id，防止重复弹出          
            , content: '<div class="container"><div class="line"><div class="loading"></div></div></div>'
            , success: function (layero) {
                dialog.closeLoading = function () {
                    layer.closeAll();
                }
            }
        });
    }
});  